package com.construction.ccb.base

import android.os.Bundle
import android.view.View
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment

/**
 * @author: FiDo
 * @date: 2024/3/11
 * @des:
 */
abstract class BaseBindingFragment<D:ViewDataBinding>(val layoutRes:Int):Fragment(layoutRes) {

    val binding:D
        get() = DataBindingUtil.bind(requireView())!!

    protected abstract fun initView()
    protected abstract fun initData()

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        DataBindingUtil.bind<D>(view)

        try {
            initView()
            initData()
        }catch (_:Exception){

        }

    }
}